package com.ruoyi.miniapp.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.miniapp.api.domain.MiniappLogininfor;
import com.ruoyi.miniapp.api.domain.MiniappOperLog;
import com.ruoyi.miniapp.api.factory.RemoteMiniappLogFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

@FeignClient(contextId = "remoteMiniappLogService", value = ServiceNameConstants.MINIAPP_SERVICE, fallbackFactory = RemoteMiniappLogFallbackFactory.class)
public interface RemoteMiniappLogService {
    /**
     * 保存系统日志
     *
     * @param miniappOperLog 日志实体
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/log")
    public R<Boolean> saveLog(@RequestBody MiniappOperLog miniappOperLog, @RequestHeader(SecurityConstants.FROM_SOURCE) String source) throws Exception;

    /**
     * 保存访问记录
     *
     * @param miniappLogininfor 访问实体
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/logininfor")
    public R<Boolean> saveLogininfor(@RequestBody MiniappLogininfor miniappLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}

